package com.yanqu.road.server.logic.activity.condition.chinesechess;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.logic.activity.BaseActivityData;
import com.yanqu.road.server.logic.activity.condition.BaseActivityCondition;

import java.math.BigInteger;
import java.util.List;

public class ChineseChessGoldTokenCondition extends BaseActivityCondition {
    public ChineseChessGoldTokenCondition(ActivityInfo activityInfo, ActivityConditionInfo activityConditionInfo, BaseActivityData baseActivityData) {
        super(activityInfo, activityConditionInfo, baseActivityData);
    }

    @Override
    protected void player_BoardLevelHandle(Object object) {
        BigInteger value = (BigInteger)object;
        setValue(value);
    }

    @Override
    public boolean isCompleted(GamePlayer player) {
        List<BigInteger> paramList = getActivityConditionInfo().getParamList();
        if(paramList.get(3).compareTo(getValue()) <= 0){
            return true;
        }
        return false;
    }

    @Override
    public void addTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().addListener(eGamePlayerEventType.ChineseChessGoldToken.getValue(), handle);
    }

    @Override
    public void removeTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().removeListener(eGamePlayerEventType.ChineseChessGoldToken.getValue(), handle);
    }
}
